/*
 * TimeBulletBill.java
 * Team qq 2011
 */
package main.java.backend.com.teamqq.timetrail;

 /**
  * Represents a box of 20 bullets
  * @author Steven
  * @version 1.0
  *
  */
public class TimeBulletBill extends Item {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3070L;

	/** Weight of one box of bullets*/
	private static final int BILL_WEIGHT = 3; 

	/** base cost of one box of bullets*/
	private static final int BILL_VALUE = 2;
	
	/** max allowed boxes of bullets*/
	private static final int BILL_MAX = Integer.MAX_VALUE;

	/** box of bullet's name*/
	private static final String BILL_NAME = "Time Bullet Bill";
	
	/** max amount of bullets per box*/
	private static final int MAX_BULLETS = 20;
	
	/** lowest amount of bullets per box*/
	private static final int MIN_BULLETS = 1;
	
	/** current amount of bullets in the box*/
	public int currentBullets;
	
	/** instantiate the bullets in the box*/
	public TimeBulletBill(){
		currentBullets = MAX_BULLETS;
	}

	/**
	 * Getter for the Weight of a box of bullets
	 * @return the weight of a box of bullets
	 */
	@Override
	public int getWeight() {
		return BILL_WEIGHT;
	}

	/**
	 * Getter for the base value of a box of bullets
	 * @return the value of a box of bullets
	 */
	@Override
	public int getValue() {
		return BILL_VALUE;
	}

	/**
	 * Getter for the maximum amount of a box of bullets
	 * @return the maximum allowed boxes
	 */
	@Override
	public int getMaxAmount() {
		return BILL_MAX;
	}

	/**
	 * Getter for the name of a box of bullets
	 * @return the name of a box of bullets
	 */
	@Override
	public String getItemName() {
		return BILL_NAME;
	}

	/**
	 * subtracts bullets from a box, will subtract the number of bill when it reaches zero
	 * @param amount the amount of bullets to use
	 */
	public void useBullets(int amount){
		final int remainder = currentBullets - amount;
		if(remainder < MIN_BULLETS){
			removeCurrentAmount(1);
			currentBullets = MAX_BULLETS - remainder;
		}
		else{
			currentBullets-=amount;
		}
	}

	/**
	 * Getter for the current number of bullets
	 * @return current amount of bullets in the box
	 */
	public int getCurrentBullets(){
		return currentBullets;
	}

}
